﻿using System.Linq;
using XRM.Security.DataAccess.Context;
using XRM.Security.DataAccess.Models;

namespace XRM.Security.DataAccess.Repositories.Impl
{
    public class SystemUserRepository : BaseRepository<SystemUser>
    {
        public SystemUserRepository(IDbContext contextDb) : base(contextDb)
        {   
        }

        public SystemUser GetByLogin(string userName)
        {
            return GetAllActive().FirstOrDefault(x => x.Login == userName);
        }

        public IQueryable<SystemUser> GetAllActive()
        {
            return GetAll( s => s.IsDeleted == false );
        }
    }
}
